﻿Imports Microsoft.VisualBasic

Public Class User
    Inherits BaseEntity

    Private _FullName As String = ""
    Public Property FullName() As String
        Get
            Return _FullName
        End Get
        Set(ByVal value As String)
            _FullName = value
        End Set
    End Property


    Private _UserName As String = ""
    Public Property UserName() As String
        Get
            Return _UserName
        End Get
        Set(ByVal value As String)
            _UserName = value
        End Set
    End Property

    Private _Password As String = ""
    Public Property Password() As String
        Get
            Return _Password
        End Get
        Set(ByVal value As String)
            _Password = value
        End Set
    End Property

    Private _UserTypeID As Short = UserType.Customber

    Public Property UserTypeID() As Short
        Get
            Return _UserTypeID
        End Get
        Set(ByVal value As Short)
            _UserTypeID = value
        End Set
    End Property


    Private _IsActive As Boolean
    Public Property IsActive() As Boolean
        Get
            Return _IsActive
        End Get
        Set(ByVal value As Boolean)
            _IsActive = value
        End Set
    End Property

    Private _IsLogin As Short
    Public Property IsLogin() As Short
        Get
            Return _IsLogin
        End Get
        Set(ByVal value As Short)
            _IsLogin = value
        End Set
    End Property

    Private _CreatedDate As DateTime
    Public Property CreatedDate() As DateTime
        Get
            Return _CreatedDate
        End Get
        Set(ByVal value As DateTime)
            _CreatedDate = value
        End Set
    End Property


    Private _ActivationCode As String
    Public Property ActivationCode() As String
        Get
            Return _ActivationCode
        End Get
        Set(ByVal value As String)
            _ActivationCode = value
        End Set
    End Property

    Private _ShippingAddress As String = ""
    Public Property ShippingAddress() As String
        Get
            Return _ShippingAddress
        End Get
        Set(ByVal value As String)
            _ShippingAddress = value
        End Set
    End Property

    Public Property UserInfo() As String
        Get
            Return _FullName & " (" & _UserName & ")"
        End Get
        Set(ByVal value As String)

        End Set
    End Property

    Public Function getUserType() As String
        If _UserTypeID = UserType.Admin Then
            Return "Admin"
        ElseIf _UserTypeID = UserType.Staff Then
        End If
        Return "Unkown"
    End Function

    Public Overrides Function ToString() As String
        Dim buf As String = Me.ID & ", " & Me.FullName & ", " & Me.UserName & ", " & Me.Password & ", " & Me.UserTypeID & ", " & _
                            Me.IsActive & ", " & Me.IsLogin & ", " & Me.CreatedDate & ", " & Me.ActivationCode & ", " & Me.ShippingAddress
        buf &= MyBase.ToString()
        Return buf
    End Function

    Public Overloads Function compareAndGetDiff(ByVal _NewObj As User) As String
        Dim buf As String = ""
        If Me.FullName <> _NewObj.FullName Then
            buf &= "FullName=" & Me.FullName & " -> " & _NewObj.FullName & " "
        End If
        If Me.UserName <> _NewObj.UserName Then
            buf &= ", Username=" & Me.UserName & " -> " & _NewObj.UserName & " "
        End If
        If Me.Password <> _NewObj.Password Then
            buf &= ", Password=" & Me.Password & " -> " & _NewObj.Password & " "
        End If
        If Me.UserTypeID <> _NewObj.UserTypeID Then
            buf &= ", UserTypeID=" & Me.UserTypeID & " -> " & _NewObj.UserTypeID & " "
        End If

        If Me.IsActive <> _NewObj.IsActive Then
            buf &= ", IsActive=" & Me.IsActive & " -> " & _NewObj.IsActive & " "
        End If

        If Me.IsLogin <> _NewObj.IsLogin Then
            buf &= ", IsLogin=" & Me.IsLogin & " -> " & _NewObj.IsLogin & " "
        End If

        If Me.ActivationCode <> _NewObj.ActivationCode Then
            buf &= ", ActivationCode=" & Me.ActivationCode & " -> " & _NewObj.ActivationCode & " "
        End If

        If Me.ShippingAddress <> _NewObj.ShippingAddress Then
            buf &= ", ShippingAddress=" & Me.ShippingAddress & " -> " & _NewObj.ShippingAddress & " "
        End If

        buf &= MyBase.compareAndGetDiff(_NewObj)
        Return buf
    End Function
End Class
